﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using KC.DataAccess.BlogSlinger;
using DAL = KC.DataAccess.BlogSlinger;

namespace Content_Bot_Controller
{
	public partial class Form1 : Form
	{
		public Form1()
		{
			InitializeComponent();
		}
		private BlogSlingerDataContext dc;

		private void Form1_Load(object sender, EventArgs e)
		{
			dc = new BlogSlingerDataContext(System.Configuration.ConfigurationManager.ConnectionStrings["SQL"].ConnectionString);
			ddlUser.DataSource = from u in dc.Users
								 orderby u.DisplayName, u.FacebookName, u.ID 
								 select u;
		}

		private void ddlUser_SelectedIndexChanged(object sender, EventArgs e)
		{
			ddlBlog.DataSource = from b in dc.Blogs
								 where b.UserRoles.Where(b2 => b2.UserID == (int)(ddlUser.SelectedValue)).Count() > 0
								 orderby b.Name
								 select b;
		}

		private void ddlBlog_SelectedIndexChanged(object sender, EventArgs e)
		{
			lbCategories.DataSource = from c in dc.Categories
									  where c.BlogID == (int)(ddlBlog.SelectedValue)
									  orderby c.Name
									  select c;
		}

		

	}
}
